/**
 * Copyright (c) 2013-1-6 下午05:01:35 WKM and/or its affiliates. 
 * Use is subject to license terms.
 * All rights reserved.
 */
package org.wkm.task.job;

import java.io.IOException;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wkm.task.file.DataReader;

/**
 * @author WKM
 * CloseSystemJob.java history
 * 1.WKM - 2013-1-6 - Create File
 */
public class CloseSystemJob implements Job {

	/** 日志信息 **/
	private static Logger logger = LoggerFactory.getLogger(CloseSystemJob.class);
	
	/** 关机命令 **/
	private String command = DataReader.getInstance().getProperty("system.exit.command");
	
	/* (non-Javadoc)
	 * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
	 */
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		// TODO Auto-generated method stub
//		Process process = null;
		try {
//			process = 
			Runtime.getRuntime().exec(command);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			logger.error("关闭计算机出现错误：" + e.getMessage());
//			logger.error("执行命令返回退出值：" + process.exitValue());
		}
		logger.info("正常退出系统.");
		System.exit(0);
	}

}
